import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/iam/v1/login',
    method: 'post',
    data
  })
}

export function logout() {
  return request({
    url: '/iam/v1/logout',
    method: 'post'
  })
}

export function listUser(data) {
  return request({
    url: '/iam/v1/users',
    method: 'post',
    data
  })
}

export function createUser(data) {
  return request({
    url: '/iam/v1/user',
    method: 'post',
    data
  })
}

export function editUser(id, data) {
  return request({
    url: '/iam/v1/user/' + id,
    method: 'put',
    data
  })
}

export function deleteUser(id) {
  return request({
    url: '/iam/v1/user/' + id,
    method: 'delete'
  })
}

export function searchUser(id) {
  return request({
    url: '/iam/v1/user/' + id,
    method: 'get'
  })
}

export function passwordUser(id, data) {
  return request({
    url: '/iam/v1/user/password/' + id,
    method: 'put',
    data
  })
}

export function userDetails() {
  return request({
    url: '/iam/v1/session',
    method: 'get'
  })
}

export function userEdit(data) {
  return request({
    url: '/iam/v1/session/save',
    method: 'put',
    data
  })
}

export function userPassword(data) {
  return request({
    url: '/iam/v1/password',
    method: 'post',
    data
  })
}

export function userSession() {
  return request({
    url: '/iam/v1/session',
    method: 'get'
  })
}
